var ws;
var game={
    room:0,
    room_number:globalData.roomNumber,
    room_url:0,score:0,
    status:0,time:-1,
    round:0,
    total_num:12,
    currentScore:0,
    cardDeal:0,
    can_open:0,
    current_win:0,
    is_play:!1,
    show_card:!1,
    show_coin:!1,
    base_score:0,
    show_score:!1,
    show_bettext:!1,
    creator_id:0,
};
var message=[
{num:0,text:"玩游戏，请先进群"},
{num:1,text:"群内游戏，切勿转发"},
{num:2,text:"别磨蹭，快点打牌"},
{num:3,text:"我出去叫人"},
{num:4,text:"你的牌好靓哇"},
{num:5,text:"我当年横扫澳门五条街"},
{num:6,text:"算你牛逼"},
{num:7,text:"别跟我抢庄"},
{num:8,text:"输得裤衩都没了"},
{num:9,text:"我给你们送温暖了"},
{num:10,text:"谢谢老板"}
];
var wsOperation={
    CreateRoom:"CreateRoom",
    JoinRoom:"JoinRoom",
    ReadyStart:"ReadyStart",
    CloseRoom:"CloseRoom",
    PrepareJoinRoom:"PrepareJoinRoom",
    AllGamerInfo:"AllGamerInfo",
    UpdateGamerInfo:"UpdateGamerInfo",
    UpdateAccountStatus:"UpdateAccountStatus",
    StartLimitTime:"StartLimitTime",
    CancelStartLimitTime:"CancelStartLimitTime",
    GameStart:"GameStart",
    NotyChooseChip:"NotyChooseChip",
    CardInfo:"CardInfo",
    PkCard:"PkCard",
    UpdateAccountScore:"UpdateAccountScore",
    OpenCard:"OpenCard",
    Win:"Win",
    Discard:"Discard",
    BroadcastVoice:"BroadcastVoice",
    CreateRoom:"CreateRoom",
    ClickToLook:"ClickToLook",
    ChooseChip:"ChooseChip",
    GrabBanker:"GrabBanker",
    PlayerMultiples:"PlayerMultiples",
    ShowCard:"ShowCard",
    UpdateAccountShow:"UpdateAccountShow",
    UpdateAccountMultiples:"UpdateAccountMultiples",
    StartBet:"StartBet",
    StartShow:"StartShow",
    RefreshRoom:"PullRoomInfo",
    BroadcastVoice:"BroadcastVoice",
    ActiveRoom:"ActivateRoom",
    MyCards:"MyCards",
    GameHistory:"HistoryScoreboard",
    GameOver:"GameOver",
    BreakRoom:"BreakRoom"
};
var httpModule={
    callbackMessage:function(){
        var e={dealer_num:globalData.dealerNum,account_id:userData.accountId,session:globalData.session};
        Vue.http.post(globalData.baseUrl+"game/callbackMessage",e).then(function(e){
            logMessage(e.body),e.body.result
        },function(e){logMessage(e.body)})
    },
    getRoomCardInfo:function(){},
    getManageInfo: function() {
        var postData = { "account_id": userData.accountId, "room_number":globalData.roomNumber,"game_type":19 };

        Vue.http.post(globalData.baseUrl + 'f/getManageInfo', postData).then(function(response) {
            logMessage(response.body);
            var bodyData = response.body;

            if (bodyData.result == 0) {
                if (bodyData.data.length == 0) {
                    if (appData.roomCard <= 0) {
                        reconnectSocket();
                        appData.is_connect = true;
                    } else {
                        reconnectSocket();
                        appData.is_connect = true;
                    }
                } else {
                    appData.activity = bodyData.data.concat();
                    viewMethods.clickShowAlert(5, appData.activity[0].content);
                }
            } else {
                //logMessage(bodyData.result_message);
                viewMethods.clickShowAlert(8, bodyData.result_message);
            }

        }, function(response) {
            logMessage(response.body);
        });
    },
};
var socketModule={
    closeSocket:function(){
        if(ws)try{ws.close()}catch(e){console.log(e)}
    },
    sendData:function(e){
        try{if(console.log("websocket state："+ws.readyState),ws.readyState==WebSocket.CLOSED)return void reconnectSocket();ws.readyState==WebSocket.OPEN?ws.send(JSON.stringify(e)):ws.readyState==WebSocket.CONNECTING?setTimeout(function(){socketModule.sendData(e)},1e3):console.log("websocket state："+ws.readyState)}catch(e){console.log(e)}
    },
    sendPrepareJoinRoom:function(){
        socketModule.sendData({operation:wsOperation.PrepareJoinRoom,account_id:userData.accountId,session:globalData.session,data:{room_number:globalData.roomNumber}})
    },
    sendGameHistory:function(){
        socketModule.sendData({operation:wsOperation.GameHistory,account_id:userData.accountId,session:globalData.session,data:{room_number:globalData.roomNumber}})
    },
    sendCreateRoom:function(){
        socketModule.sendData({operation:wsOperation.CreateRoom,account_id:userData.accountId,session:globalData.session,data:{data_key:Date.parse(new Date)+randomString(5),ticket_type:appData.createInfo.ticket,score_type:appData.createInfo.baseScore,rule_type:appData.createInfo.timesType,is_cardfive:appData.createInfo.isCardfive,is_cardbomb:appData.createInfo.isCardbomb,is_cardtiny:appData.createInfo.isCardtiny,banker_mode:appData.createInfo.banker_mode,banker_score_type:appData.createInfo.banker_score}})
    },
    sendJoinRoom:function(){
        socketModule.sendData({operation:wsOperation.JoinRoom,account_id:userData.accountId,session:globalData.session,data:{room_number:globalData.roomNumber}})
    },
    sendRefreshRoom:function(){
        socketModule.sendData({operation:wsOperation.RefreshRoom,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room}})
    },
    sendReadyStart:function(){
        socketModule.sendData({operation:wsOperation.ReadyStart,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room}})
    },
    sendCloseRoom:function(){
        socketModule.sendData({operation:wsOperation.CloseRoom,account_id:userData.accountId,session:globalData.session,data:{room_number:globalData.roomNumber}})
    },
    sendGameOver:function(){
        socketModule.sendData({operation:wsOperation.GameOver,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room}})
    },
    sendBroadcastVoice:function(e){
        socketModule.sendData({operation:wsOperation.BroadcastVoice,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room,voice_num:e}})
    },
    sendGrabBanker:function(e){
        socketModule.sendData({operation:wsOperation.GrabBanker,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room,is_grab:"1",multiples:e}})
    },
    sendNotGrabBanker:function(){
        socketModule.sendData({operation:wsOperation.GrabBanker,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room,is_grab:"0",multiples:"1"}})
    },
    sendPlayerMultiples:function(e){
        socketModule.sendData({operation:wsOperation.PlayerMultiples,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room,multiples:e}})
    },
    sendShowCard:function(){
        socketModule.sendData({operation:wsOperation.ShowCard,account_id:userData.accountId,session:globalData.session,data:{room_id:appData.game.room}})
    },
    processGameHistory:function(e){
        appData.recordList=[];for(var t=0;t<e.data.length;t++)appData.recordList.push({time:getLocalTime(e.data[t].time),scoreboard:e.data[t].scoreboard});appData.isShowRecord=!0
    },
    processGameRule:function(e){
        if(e.data.ticket_type){
            appData.ruleInfo.ticket=e.data.ticket_type;
            appData.ruleInfo.baseScore=e.data.score_type;
            appData.ruleInfo.timesType=e.data.rule_type;
            appData.ruleInfo.isCardfive=Math.ceil(e.data.is_cardfive);
            appData.ruleInfo.isCardbomb=Math.ceil(e.data.is_cardbomb);
            appData.ruleInfo.isCardtiny=Math.ceil(e.data.is_cardtiny);
            appData.ruleInfo.banker_mode=Math.ceil(e.data.banker_mode);
            appData.ruleInfo.banker_score=Math.ceil(e.data.banker_score_type);
        }
        appData.ruleInfo.rule_height="4vh";
        if(1==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="抢庄";
        } else if(2==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="抢庄";
        } else if(3==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="选庄";
        } else if(4==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="";
        } else if(5==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="";
        }
    },
    processPrepareJoinRoom:function(e){
        if(4==e.data.room_status){
            appData.roomStatus=e.data.room_status;
            viewMethods.clickShowAlert(2,e.result_message);
            return; 
        }
        if(e.data.ticket_type){
            appData.ruleInfo.ticket=e.data.ticket_type;
            appData.ruleInfo.baseScore=e.data.score_type;
            appData.ruleInfo.timesType=e.data.rule_type;
            appData.ruleInfo.isCardfive=Math.ceil(e.data.is_cardfive);
            appData.ruleInfo.isCardbomb=Math.ceil(e.data.is_cardbomb);
            appData.ruleInfo.isCardtiny=Math.ceil(e.data.is_cardtiny);
            appData.ruleInfo.banker_mode=Math.ceil(e.data.banker_mode);
            appData.ruleInfo.banker_score=Math.ceil(e.data.banker_score_type);
        }

        appData.ruleInfo.rule_height="4vh";

        if(1==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="抢庄";
        } else if(2==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="抢庄";
        } else if(3==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="选庄";
        } else if(4==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="";
        } else if(5==appData.ruleInfo.banker_mode){
            appData.ruleInfo.bankerText="";
        }

        wxModule.config();

        if(3!=e.data.room_status){
            if(0==e.data.user_count){
                socketModule.sendJoinRoom();
            } else {
                if(""!=e.data.alert_text){
                    viewMethods.clickShowAlert(4,e.data.alert_text);
                } else {
                    socketModule.sendJoinRoom();
                }
            }
        } else {
            $(".createRoom .mainPart").css("height","65vh");
            $(".createRoom .mainPart .blueBack").css("height","46vh");
        }
    },
    processJoinRoom:function(e){
        appData.game.room=e.data.room_id;
        appData.game.room_url=e.data.room_url;
        appData.game.currentScore=Math.ceil(e.data.benchmark);
        appData.game.score=Math.ceil(e.data.pool_score);
        appData.game.round=Math.ceil(e.data.game_num);
        appData.game.total_num=Math.ceil(e.data.total_num);
        appData.game.base_score=Math.ceil(e.data.base_score);
        appData.game.creator_id=Math.ceil(e.data.creator_id);
        appData.base_score=appData.game.base_score;
        appData.canBreak=Math.ceil(e.data.can_break);
        resetAllPlayerData();
        -1==e.data.limit_time&&(appData.game.time=Math.ceil(e.data.limit_time),viewMethods.timeCountDown());
        appData.player[0].serial_num=e.data.serial_num;
        for(var t=0;t<9;t++)
            t<=9-e.data.serial_num?
        appData.player[t].serial_num=t+Math.ceil(e.data.serial_num):
        appData.player[t].serial_num=t+Math.ceil(e.data.serial_num)-9;

        console.log(appData.player);
        appData.player[0].account_status=Math.ceil(e.data.account_status);
        appData.player[0].account_score=Math.ceil(e.data.account_score);
        appData.player[0].nickname=userData.nickname;
        appData.player[0].headimgurl=userData.avatar;
        appData.player[0].account_id=userData.accountId;
        appData.player[0].card=e.data.cards.concat();
        appData.player[0].card_open=e.data.combo_array.concat();
        appData.player[0].card_type=e.data.card_type;
        appData.player[0].ticket_checked=e.data.ticket_checked;
        appData.game.status=Math.ceil(e.data.room_status);
        appData.player[0].combo_point=e.data.combo_point;
        appData.player[0].card_open=e.data.cards.concat();
        5==appData.ruleInfo.banker_mode&&1==appData.game.round?
        appData.player[0].account_status>5&&(appData.game.cardDeal=5):
        2==appData.game.status&&(appData.game.cardDeal=5);
        appData.scoreboard=e.data.scoreboard;
        console.log("451: resetMyAccountStatus");
        viewMethods.resetMyAccountStatus();
    },
    processRefreshRoom:function(e){
        resetAllPlayerData();
        appData.player[0].serial_num=e.data.serial_num;
        for(t=0;t<9;t++)
            if(t<=9-e.data.serial_num){
                appData.player[t].serial_num=t+Math.ceil(e.data.serial_num);
            } else {
                appData.player[t].serial_num=t+Math.ceil(e.data.serial_num)-9;
            }
        appData.player[0].account_status=Math.ceil(e.data.account_status);
        appData.player[0].account_score=Math.ceil(e.data.account_score);
        appData.player[0].nickname=userData.nickname;
        appData.player[0].headimgurl=userData.avatar;
        appData.player[0].account_id=userData.accountId;
        appData.player[0].serial_num=e.data.serial_num;
        appData.player[0].card=e.data.cards.concat();
        appData.player[0].card_open=e.data.combo_array.concat();
        appData.player[0].card_type=e.data.card_type;
        appData.player[0].ticket_checked=e.data.ticket_checked;
        appData.player[0].combo_point=e.data.combo_point;
        appData.player[0].card_open=e.data.cards.concat();
        if(5==appData.ruleInfo.banker_mode&&1==appData.game.round){
            appData.player[0].account_status>5&&(appData.game.cardDeal=5);
        } else {
            2==appData.game.status&&(appData.game.cardDeal=5);
        }

        for(var t=0;t<9;t++)
            for(var a=0;a<e.all_gamer_info.length;a++)
                if(appData.player[t].serial_num==e.all_gamer_info[a].serial_num){
                    appData.player[t].nickname=e.all_gamer_info[a].nickname;
                    appData.player[t].headimgurl=e.all_gamer_info[a].headimgurl;
                    appData.player[t].account_id=e.all_gamer_info[a].account_id;
                    appData.player[t].account_code=e.all_gamer_info[a].account_code;
                    appData.player[t].account_score=Math.ceil(e.all_gamer_info[a].account_score);
                    appData.player[t].account_status=Math.ceil(e.all_gamer_info[a].account_status);
                    appData.player[t].online_status=Math.ceil(e.all_gamer_info[a].online_status);
                    appData.player[t].ticket_checked=e.all_gamer_info[a].ticket_checked;
                    appData.player[t].multiples=e.all_gamer_info[a].multiples;
                    appData.player[t].bankerMultiples=e.all_gamer_info[a].banker_multiples;
                    appData.player[t].card_type=e.all_gamer_info[a].card_type;
                    appData.player[t].combo_point=e.all_gamer_info[a].combo_point;
                    appData.player[t].is_showbull=!1;

                    if(1==e.all_gamer_info[a].is_banker){
                        appData.player[t].is_banker=!0;
                        appData.bankerAccountId=e.all_gamer_info[a].account_id;
                        appData.bankerPlayer=appData.player[t];
                    } else {
                        appData.player[t].is_banker=!1;
                    }
                    if(appData.player[t].account_status>=8){
                        appData.player[t].is_showCard=!0;
                    }

                    appData.player[t].card_open=e.all_gamer_info[a].cards.concat();
                    if(appData.player[t].card_open.length<1||void 0==appData.player[t].card_open){
                        appData.player[t].card_open=[-1,-1];
                    }
                }

        appData.player[0].account_status>=7&&(appData.player[0].is_showCard=!0);
        if(appData.player[0].account_status>2){
            setTimeout(function(){
                5==appData.ruleInfo.banker_mode&&1==appData.game.round||(appData.player[0].is_showCard=!0)
            },500);
        }
        if(3==appData.player[0].account_status){
            5==appData.ruleInfo.banker_mode&&1==appData.game.round||(appData.showClockRobText=!0);
            setTimeout(function(){appData.showRob=!0},500);
        }
        if(6==appData.player[0].account_status){
            appData.showClockBetText=!0;
            if(1==appData.player[0].is_banker){
                appData.showRob=!1;
                appData.showRobText=!1;
                appData.showNotRobBankerText=!1;
                appData.showShowCardButton=!1;
                appData.showClickShowCard=!1;
                appData.showBankerCoinText=!0;
                appData.showTimesCoin=!1;
            } else {
                appData.showRob=!1;
                appData.showRobText=!1;
                appData.showNotRobBankerText=!1;
                appData.showShowCardButton=!1;
                appData.showClickShowCard=!1;
                appData.showBankerCoinText=!1;
                appData.showTimesCoin=!0;
            }
        }
        if(6==appData.player[0].account_status)
            appData.isFinishBankerAnimate=!0;
        viewMethods.resetMyAccountStatus();
        viewMethods.updateAllPlayerStatus();
        if(appData.player[0].account_status>2&&appData.player[0].account_status<7&&2==appData.ruleInfo.banker_mode){
            viewMethods.seeMyCard();
        }
    },
    processStartShow:function(e){
        var t=0;
        4==appData.ruleInfo.banker_mode&&(t=1200);
        setTimeout(function(){
            for(var t=0;t<9;t++)
                for(var a=0;a<e.data.length;a++)
                    if(appData.player[t].account_id==e.data[a].account_id){
                        appData.player[t].multiples=e.data[a].multiples;
                        appData.player[t].account_status=Math.ceil(e.data[a].account_status);
                        appData.player[t].online_status=Math.ceil(e.data[a].online_status);
                        appData.player[t].card=e.data[a].cards.concat();
                        appData.player[t].card_open=e.data[a].combo_array.concat();
                        appData.player[t].card_type=e.data[a].card_type;
                        appData.player[t].combo_point=e.data[a].combo_point;
                        appData.player[t].limit_time=e.data[a].limit_time;
                        appData.player[t].card_open=e.data[a].cards.concat();
                    }
            appData.showClockBetText=!1;
            appData.showClockRobText=!1;
            appData.showClockShowCard=!0;
            console.log("581: resetMyAccountStatus");
            viewMethods.resetMyAccountStatus();
            viewMethods.updateAllPlayerStatus();
            appData.game.time=Math.ceil(e.limit_time);
            viewMethods.timeCountDown();
        },t);
    },
    processMyCards:function(e){
        if(2==appData.ruleInfo.banker_mode){
            if(appData.player[0].account_id==e.data.account_id){
                appData.player[0].card=e.data.cards.concat();
                console.log(appData.player[0].card);
            }
            viewMethods.seeMyCard();
        }
    },
    processBreakRoom:function(e){
        if(appData.breakData=e,5==appData.ruleInfo.banker_mode&&appData.game.round!=appData.game.total_num)return null==e||void 0==e?(appData.overType=2,void viewMethods.clickShowAlert(9,"庄家分数不足，提前下庄，点击确定查看结算")):void(1==e.data.type?appData.player[0].is_banker?(viewMethods.clickCloseAlert(),null!=appData.breakData&&void 0!=appData.breakData&&viewMethods.gameOverNew(appData.breakData.data.score_board,appData.breakData.data.balance_scoreboard),chooseBigWinner(),$(".ranking .rankBack").css("opacity","1"),$(".roundEndShow").show(),$(".ranking").show(),canvas()):(appData.overType=1,viewMethods.clickShowAlert(9,"庄家主动下庄,点击确定查看结算")):appData.overType=e.data.type)
    },
    processStartBet:function(e){
        var t=0;3==appData.ruleInfo.banker_mode&&(t=1500),5==appData.ruleInfo.banker_mode&&appData.game.round>1&&(t=1200),1==appData.game.round&&appData.ruleInfo.banker_mode,setTimeout(function(){for(var t=0;t<9;t++)for(var a=0;a<e.data.length;a++)appData.player[t].account_id==e.data[a].account_id&&(appData.player[t].account_status=Math.ceil(e.data[a].account_status),appData.player[t].online_status=Math.ceil(e.data[a].online_status),appData.player[t].limit_time=Math.ceil(e.data[a].limit_time),appData.player[t].multiples=0,1==e.data[a].is_banker?(appData.player[t].is_banker=!0,appData.bankerAccountId=e.data[a].account_id,appData.bankerPlayer=appData.player[t]):appData.player[t].is_banker=!1);appData.bankerArray=e.grab_array.concat(),appData.showRob=!1,appData.showClockBetText=!1,appData.showClockRobText=!1,appData.showClockShowCard=!1,appData.game.time=Math.ceil(e.limit_time),appData.bankerAnimateIndex=0,appData.game.time=-1,5==appData.ruleInfo.banker_mode&&appData.game.round>1?viewMethods.robBankerWithoutAnimate():3==appData.ruleInfo.banker_mode&&appData.game.round>1?viewMethods.robBankerWithoutAnimate():(viewMethods.clearBanker(),viewMethods.robBankerAnimate(e))},t)
    },
    processAllGamerInfo:function(e){
        appData.game.show_card=!0;
        appData.game.show_coin=!0;
        appData.clickCard4=!1;
        for(a=0;a<9;a++)
            for(var t=0;t<e.data.length;t++)
                if(appData.player[a].serial_num==e.data[t].serial_num){
                    appData.player[a].nickname=e.data[t].nickname;
                    appData.player[a].headimgurl=e.data[t].headimgurl;
                    appData.player[a].account_id=e.data[t].account_id;
                    appData.player[a].account_code=e.data[t].account_code;
                    appData.player[a].account_score=Math.ceil(e.data[t].account_score);
                    appData.player[a].account_status=Math.ceil(e.data[t].account_status);
                    appData.player[a].online_status=Math.ceil(e.data[t].online_status);
                    appData.player[a].ticket_checked=e.data[t].ticket_checked;
                    appData.player[a].multiples=e.data[t].multiples;
                    appData.player[a].bankerMultiples=e.data[t].banker_multiples;
                    appData.player[a].card_type=e.data[t].card_type;
                    appData.player[a].combo_point=e.data[t].combo_point;
                    appData.player[a].is_showbull=!1;

                    if(1==e.data[t].is_banker){
                        appData.player[a].is_banker=!0;
                        appData.bankerAccountId=e.data[t].account_id;
                        appData.bankerPlayer=appData.player[a];       
                    } else {
                       appData.player[a].is_banker=!1; 
                    }
                    appData.player[a].account_status>=8&&(appData.player[a].is_showCard=!0);
                    appData.player[a].card_open=e.data[t].cards.concat();

                    if(appData.player[a].card_open.length<1||void 0==appData.player[a].card_open){
                        appData.player[a].card_open=[-1,-1,-1,-1,-1];
                    }
                }
        if(appData.player[0].account_status>=7){
            appData.player[0].is_showCard=!0;
        }
        if(""!=appData.scoreboard){
            for(var a=0;a<9;a++)
                for(s in appData.scoreboard)
                    if(appData.player[a].account_id==s){
                        appData.playerBoard.score[a].num=appData.player[a].num;
                        appData.playerBoard.score[a].account_id=appData.player[a].account_id;
                        appData.playerBoard.score[a].nickname=appData.player[a].nickname;
                        appData.playerBoard.score[a].account_score=Math.ceil(appData.scoreboard[s]);
                    }
            if(2==appData.game.status){
                appData.playerBoard.round=appData.game.round-1;
            } else {
                appData.playerBoard.round=appData.game.round;
            }
        }
        if(appData.player[0].account_status>2){
            setTimeout(function(){5==appData.ruleInfo.banker_mode&&1==appData.game.round||(appData.player[0].is_showCard=!0)},500);
        }

        if(3==appData.player[0].account_status){
            5==appData.ruleInfo.banker_mode&&1==appData.game.round||(appData.showClockRobText=!0),setTimeout(function(){appData.showRob=!0},500);
        }
        if(6==appData.player[0].account_status){
            appData.showClockBetText=!0;
            if(1==appData.player[0].is_banker){
                appData.showRob=!1;
                appData.showRobText=!1;
                appData.showNotRobBankerText=!1;
                appData.showShowCardButton=!1;
                appData.showClickShowCard=!1;
                appData.showBankerCoinText=!0;
                appData.showTimesCoin=!1;
            } else {
                appData.showRob=!1;
                appData.showRobText=!1;
                appData.showNotRobBankerText=!1;
                appData.showShowCardButton=!1;
                appData.showClickShowCard=!1;
                appData.showBankerCoinText=!1;
                appData.showTimesCoin=!0;
            }
        }

        if(6==appData.player[0].account_status)
            appData.isFinishBankerAnimate=!0;
        viewMethods.resetMyAccountStatus();
        viewMethods.updateAllPlayerStatus();
        if(appData.player[0].account_status>2&&appData.player[0].account_status<7&&2==appData.ruleInfo.banker_mode){
            viewMethods.seeMyCard();
        }
    },
    processUpdateGamerInfo:function(e){
        logMessage(appData.player);for(var t=0;t<9;t++)appData.player[t].serial_num==e.data.serial_num?(appData.player[t].nickname=e.data.nickname,appData.player[t].headimgurl=e.data.headimgurl,appData.player[t].account_id=e.data.account_id,appData.player[t].account_code=e.data.account_code,appData.player[t].account_score=Math.ceil(e.data.account_score),appData.player[t].account_status=Math.ceil(e.data.account_status),appData.player[t].online_status=Math.ceil(e.data.online_status),appData.player[t].ticket_checked=e.data.ticket_checked):appData.player[t].account_id==e.data.account_id&&socketModule.sendRefreshRoom()
    },
    processUpdateAccountStatus:function(e){
        for(var t=0;t<9;t++)if(appData.player[t].account_id==e.data.account_id){if(2==appData.ruleInfo.banker_mode&&(5!=e.data.account_status&&4!=e.data.account_status||(appData.player[t].bankerMultiples=e.data.banker_multiples)),appData.player[t].account_status>=8)return void(appData.player[t].online_status=e.data.online_status);1==e.data.online_status?appData.player[t].account_status=Math.ceil(e.data.account_status):0==e.data.online_status&&0==appData.player[t].account_status?(appData.player[t].account_id=0,appData.player[t].playing_status=0,appData.player[t].online_status=0,appData.player[t].nickname="",appData.player[t].headimgurl="",appData.player[t].account_score=0):0==e.data.online_status&&appData.player[t].account_status>0?(appData.player[t].account_status=Math.ceil(e.data.account_status),appData.player[t].online_status=0):logMessage("~~~~~~~!!!!!!"+e),0!=t&&(4==appData.player[t].account_status?setTimeout(function(){mp3AudioPlay("audioNoBanker")},100):5==appData.player[t].account_status&&setTimeout(function(){mp3AudioPlay("audioRobBanker")},100));break}3==appData.player[0].account_status?viewMethods.showRobBankerText():4==appData.player[0].account_status&&viewMethods.showNotRobBankerTextFnc(),appData.isFinishBankerAnimate&&appData.isFinishWinAnimate?(console.log("802: resetMyAccountStatus"),viewMethods.resetMyAccountStatus(),viewMethods.updateAllPlayerStatus()):setTimeout(function(){console.log("797: resetMyAccountStatus"),viewMethods.resetMyAccountStatus(),viewMethods.updateAllPlayerStatus()},3e3)
    },
    processUpdateAccountShow:function(e){
        for(var t=0;t<appData.player.length;t++)if(appData.player[t].account_id==e.data.account_id){if(appData.player[t].card_type=e.data.card_type,appData.player[t].cards=e.data.cards.concat(),appData.player[t].card_open=e.data.combo_array.concat(),appData.player[t].combo_point=e.data.combo_point,appData.player[t].account_status=8,appData.player[t].card_open=e.data.cards.concat(),0==appData.player[t].is_audiobull&&appData.player[t].account_status>=8){var a="";a=1==appData.player[t].card_type?"point"+appData.player[t].combo_point:"type"+appData.player[t].card_type,setTimeout(function(){mp3AudioPlay(a)},100),appData.player[t].is_audiobull=!0}break}e.data.account_id==appData.player[0].account_id&&(console.log("841: resetMyAccountStatus"),viewMethods.resetMyAccountStatus()),viewMethods.updateAllPlayerStatus()
    },
    processUpdateAccountMultiples:function(e){
        for(var t=0;t<appData.player.length;t++)if(appData.player[t].account_id==e.data.account_id){if(appData.player[t].multiples=e.data.multiples,0==t)return;if(appData.player[t].multiples>=1){var a=appData.player[t].multiples;setTimeout(function(){mp3AudioPlay("audioTimes"+a)},100)}break}console.log("864: resetMyAccountStatus"),viewMethods.resetMyAccountStatus(),viewMethods.updateAllPlayerStatus()
    },
    processStartLimitTime:function(e){
        e.data.limit_time>1&&(appData.game.time=Math.ceil(e.data.limit_time),viewMethods.timeCountDown())
    },
    processCancelStartLimitTime:function(e){
        appData.game.time=-1
    },
    processGameStart:function(e){
        $(".cards").removeClass("card-flipped"),$(".myCards").removeClass("card-flipped"),$(".memberCoin").stop(!0),appData.isFinishWinAnimate=!0,appData.isFinishBankerAnimate=!0,appData.game.can_open=0,appData.game.cardDeal=0,appData.game.currentScore=0,appData.game.status=1,appData.game.show_card=!0,appData.game.score=0,appData.game.time=-1,appData.game.is_play=!0,appData.game.round=appData.game.round+1,appData.game.round=Math.ceil(e.game_num),appData.player[0].is_showCard=!1,appData.showClockRobText=!1,appData.showClockBetText=!1,appData.showClockShowCard=!1,appData.clickCard4=!1,appData.showClickShowCard=!1,appData.breakData=null;for(var t=0;t<9;t++){appData.player[t].is_operation=!1,appData.player[t].is_showCard=!1,appData.player[t].is_showbull=!1,5==appData.ruleInfo.banker_mode&&appData.game.round>1||3==appData.ruleInfo.banker_mode&&appData.game.round>1||(appData.player[t].is_banker=!1),appData.player[t].bullImg="",0==appData.player[t].online_status&&(appData.player[t].account_status=1);for(var a=0;a<e.data.length;a++)appData.player[t].account_id==e.data[a].account_id&&(0==appData.player[t].ticket_checked&&0==t&&1==appData.isAA&&(2==appData.ruleInfo.ticket?appData.roomCard=appData.roomCard-4:appData.roomCard=appData.roomCard-2),appData.player[t].ticket_checked=1,appData.player[t].account_status=Math.ceil(e.data[a].account_status),appData.player[t].playing_status=Math.ceil(e.data[a].playing_status),appData.player[t].online_status=Math.ceil(e.data[a].online_status),appData.player[t].account_score=appData.player[t].account_score,appData.player[t].limit_time=Math.ceil(e.data[a].limit_time),appData.game.score=appData.game.score)}appData.game.status=2,1==appData.game.round&&5==appData.ruleInfo.banker_mode?(appData.game.time=-1,viewMethods.resetMyAccountStatus()):(appData.game.time=Math.ceil(e.limit_time),viewMethods.timeCountDown(),viewMethods.reDeal())
    },
    processBroadcastVoice:function(e){
        for(var t=0;t<9;t++)appData.player[t].account_id==e.data.account_id&&0!=t&&(m4aAudioPlay("message"+e.data.voice_num),viewMethods.messageSay(t,e.data.voice_num))
    },
    processCreateRoom:function(e){
        window.location.href=globalData.baseUrl+"game/bull9?dealer_num="+globalData.dealerNum+"&room_number="+e.data.room_number
    },
    processWin:function(e){
        appData.game.is_play=!1,appData.game.current_win=e.data.win_score,appData.game.round=Math.ceil(e.data.game_num),appData.game.total_num=Math.ceil(e.data.total_num),appData.playerBoard.round=Math.ceil(e.data.game_num),appData.game.show_score=!1,appData.showClockShowCard=!1,appData.showShowCardButton=!1,appData.showClickShowCard=!1,appData.showClockBetText=!1,appData.showClockRobText=!1,3==appData.ruleInfo.banker_mode&&(appData.bankerID=Math.ceil(e.data.banker_id),appData.bankerAccountId=appData.bankerID,console.log(appData.bankerID)),5==appData.ruleInfo.banker_mode&&(appData.player[0].is_banker&&(appData.canBreak=Math.ceil(e.data.can_break)),null==e.data.is_break&&void 0==e.data.is_break||(appData.isBreak=Math.ceil(e.data.is_break))),viewMethods.showMemberScore(!1);for(var t=0;t<appData.player.length;t++){appData.player[t].account_status>=7&&(appData.player[t].account_status=8);for(var a=0;a<e.data.loser_array.length;a++)if(appData.player[t].account_id==e.data.loser_array[a].account_id){appData.player[t].single_score=e.data.loser_array[a].score;break}for(var n=0;n<e.data.winner_array.length;n++)if(appData.player[t].account_id==e.data.winner_array[n].account_id){appData.player[t].single_score=e.data.winner_array[n].score;break}}if(appData.game.time=-1,viewMethods.updateAllPlayerStatus(),setTimeout(function(){console.log("983: resetMyAccountStatus"),viewMethods.resetMyAccountStatus()},200),appData.player[0].account_status>=8&&0==appData.player[0].is_audiobull){var o=appData.player[0].card_type,i=appData.player[0].combo_point;setTimeout(function(){audio=1==o?"point"+i:"type"+o,mp3AudioPlay(audio)},200),appData.player[0].is_audiobull=!0}setTimeout(function(){viewMethods.winAnimate(e)},3e3)
    },
    processBalanceScoreboard:function(e){
        var t=new Date(1e3*parseInt(e.time)),a=t.getFullYear()+"-",n=t.getMonth()+1+"-",o=t.getDate()+" ",i=t.getHours(),r=t.getMinutes(),c=":";r<10&&(c+=0);var l=a+n+o+i+c+r;appData.playerBoard.round=e.game_num,appData.playerBoard.record=l,appData.playerBoard.score=[];var u=e.scoreboard;for(s in u){var p=0,d=u[s].name;userData.accountId==u[s].account_id&&(p=1),appData.playerBoard.score.push({account_id:u[s].account_id,nickname:d,account_score:Math.ceil(u[s].score),num:p,account_code:u[s].account_code})}
    },
    processLastScoreboard:function(e){
        if(void 0!=e){console.log(e);try{var t=new Date(1e3*parseInt(e.time)),a=t.getFullYear()+"-",n=t.getMonth()+1+"-",o=t.getDate()+" ",i=t.getHours(),r=t.getMinutes(),c=":";r<10&&(c+=0);var l=a+n+o+i+c+r;appData.playerBoard.round=e.game_num,appData.playerBoard.record=l,appData.playerBoard.score=[],void 0!=e.total_num&&null!=e.total_num&&""!=e.total_num&&(appData.game.total_num=e.total_num);var u=e.scoreboard;for(s in u){var p=0;userData.accountId==u[s].account_id&&(p=1),appData.playerBoard.score.push({account_id:u[s].account_id,nickname:u[s].name,account_score:Math.ceil(u[s].score),num:p,account_code:u[s].account_code})}chooseBigWinner(),$(".ranking .rankBack").css("opacity","1"),$(".roundEndShow").show(),$(".ranking").show(),canvas(),$("#endCreateRoomBtn").show()}catch(e){console.log(e)}}
    }
};

var viewMethods={
    clickGameOver:function(){viewMethods.clickShowAlert(10,"下庄之后，将以当前战绩进行结算。是否确定下庄？")},
    clickCreateRoom:function(){$(".createRoom .mainPart").css("height","65vh"),$(".createRoom .mainPart .blueBack").css("height","46vh"),appData.createInfo.type=1,appData.createInfo.isShow=!0},
    clickShowInvite:function(){appData.isShowInvite=!0},
    clickCloseInvite:function(){appData.isShowInvite=!1},
    clickShowAlert:function(e,t){appData.alertType=e,appData.alertText=t,appData.isShowAlert=!0,setTimeout(function(){var t=$(".alertText").height(),a=t;t<.15*height&&(t=.15*height),t>.8*height&&(t=.8*height);var n=t+.056*height*2+.022*height+.056*height;8==e&&(n=n-.022*height-.056*height);var o=t+.034*height*2,i=.022*height+(o-a)/2;$(".alert .mainPart").css("height",n+"px"),$(".alert .mainPart").css("margin-top","-"+n/2+"px"),$(".alert .mainPart .backImg .blackImg").css("height",o+"px"),$(".alert .mainPart .alertText").css("top",i+"px")},0)},
    clickCloseAlert:function(){1==appData.alertType?(appData.isShowAlert=!1,appData.is_connect||(reconnectSocket(),appData.is_connect=!0)):22==appData.alertType?(appData.isShowAlert=!1,httpModule.getManageInfo()):appData.isShowAlert=!1},
    clickSitDown:function(){appData.isShowAlert=!1,socketModule.sendJoinRoom()},
    clickReady:function(){socketModule.sendReadyStart(),appData.player[0].is_operation=!0},
    clickCloseRoom:function(){socketModule.sendCloseRoom(),appData.player[0].is_operation=!0},
    reDeal:function(){appData.isDealing||(console.log("~~~~reDeal~~~~~"),appData.isDealing=!0,m4aAudioPlay("audio1"),appData.game.cardDeal=1,setTimeout(function(){appData.game.cardDeal=2,setTimeout(function(){console.log("1139: resetMyAccountStatus"),viewMethods.resetMyAccountStatus(),appData.player[0].is_showCard=!0,appData.showClockRobText=!0,appData.isDealing=!1,5==appData.ruleInfo.banker_mode&&1==appData.game.round&&viewMethods.updateAllPlayerStatus()},300)},150))},
    resetMyAccountStatus:function(){
        (6!=appData.player[0].account_status||appData.isFinishBankerAnimate)&&(viewMethods.resetShowButton(),3==appData.player[0].account_status?appData.showRob=!0:4==appData.player[0].account_status?appData.showNotRobText=!0:5==appData.player[0].account_status?appData.showRobText=!0:6==appData.player[0].account_status?1==appData.player[0].is_banker?appData.showBankerCoinText=!0:appData.isFinishBankerAnimate&&(appData.showTimesCoin=!0):7==appData.player[0].account_status?(appData.player[0].is_showCard=!0,1==appData.clickCard4?appData.showShowCardButton=!0:appData.showClickShowCard=!0):8==appData.player[0].account_status&&(appData.player[0].is_showCard=!0))},
    resetShowButton:function(){
        appData.showTimesCoin=!1,appData.showRob=!1,appData.showShowCardButton=!1,appData.showClickShowCard=!1,appData.showNotRobText=!1,appData.showRobText=!1,appData.showBankerCoinText=!1
    },
    seeMyCard:function(){
        if(2==appData.ruleInfo.banker_mode){
            setTimeout(function(){
                $(".myCards .card0").addClass("card-flipped"),
                setTimeout(function(){
                    1!=appData.clickCard4&&7==appData.player[0].account_status&&(appData.showClickShowCard=!0)
                },500)
            },1e3)
        } else {
            setTimeout(function(){
                $(".myCards .card0").addClass("card-flipped"),
                setTimeout(function(){
                    appData.clickCard4||(appData.showClickShowCard=!0)
                },500)
            },350)
        }
    },
    seeMyCard4:function(){
        appData.player[0].account_status>=7&&($(".myCards .card1").addClass("card-flipped"),appData.clickCard4=!0,setTimeout(function(){appData.showShowCardButton=!0,appData.showClickShowCard=!1},100))
    },
    myCardOver:function(e){$(".myCards .card").addClass("card-flipped")},
    cardOver:function(e,t){e<=1||setTimeout(function(){$(".cardOver .card"+e).addClass("card-flipped")},1)},
    gameOverNew:function(e,t){appData.game.show_coin=!1;for(o=0;o<appData.playerBoard.score.length;o++)appData.playerBoard.score[o].num=0,appData.playerBoard.score[o].account_id=0,appData.playerBoard.score[o].nickname="",appData.playerBoard.score[o].account_score=0,appData.playerBoard.score[o].isBigWinner=0,appData.playerBoard.score[o].account_code="";console.log(appData.playerBoard);for(o=0;o<9;o++)for(s in e)appData.player[o].account_id==s&&(appData.player[o].account_score=Math.ceil(e[s]),appData.playerBoard.score[o].num=appData.player[o].num,appData.playerBoard.score[o].account_id=appData.player[o].account_id,appData.playerBoard.score[o].nickname=appData.player[o].nickname,appData.playerBoard.score[o].account_score=appData.player[o].account_score,appData.playerBoard.score[o].account_code=appData.player[o].account_code);var a=new Date,n="";n+=a.getFullYear()+"-",n+=a.getMonth()+1+"-",n+=a.getDate()+"  ",n+=a.getHours()+":",a.getMinutes()>=10?n+=a.getMinutes():n+="0"+a.getMinutes(),appData.playerBoard.record=n,appData.base_score=appData.game.base_score,void 0!=t&&"-1"!=t&&(console.log(t),socketModule.processBalanceScoreboard(t));for(var o=0;o<9;o++)appData.player[o].playing_status=0,appData.player[o].is_win=!1,appData.player[o].is_operation=!1,appData.player[o].win_type=0,appData.player[o].win_show=!1,appData.player[o].card=new Array,appData.player[o].card_open=new Array,appData.player[o].card_type=0,appData.player[o].is_showCard=!1,appData.player[o].is_readyPK=!1,appData.player[o].is_pk=!1,appData.player[o].multiples=0,appData.player[o].bankerMultiples=0,appData.player[o].is_bull=!1,appData.player[o].is_showbull=!1,appData.player[o].is_audiobull=!1;appData.game.can_open=0,appData.game.score=0,appData.game.cardDeal=0,appData.game.currentScore=0,appData.game.status=1,appData.player[0].is_showCard=!1,appData.showClockRobText=!1,appData.showClockBetText=!1,appData.showClockShowCard=!1},
    showMessage:function(){appData.isShowMessage=!0,disable_scroll(),setTimeout(function(){appData.bScroll?appData.bScroll.refresh():appData.bScroll=new BScroll(document.getElementById("message-box"),{startX:0,startY:0,scrollY:!0,scrollX:!1,click:!0})},10)},
    hideMessage:function(){appData.isShowMessage=!1,enable_scroll()},
    messageOn:function(e){socketModule.sendBroadcastVoice(e),m4aAudioPlay("message"+e),viewMethods.messageSay(0,e),viewMethods.hideMessage()},
    messageSay:function(e,t){appData.player[e].messageOn=!0,appData.player[e].messageText=appData.message[t].text,setTimeout(function(){appData.player[e].messageOn=!1},2500)},
    closeEnd:function(){},
    roundEnd:function(){chooseBigWinner(),$(".ranking .rankBack").css("opacity","1"),$(".roundEndShow").show(),setTimeout(function(){$(".ranking").show(),canvas()},2500)},
    updateAllPlayerStatus:function(){
        for(var e=0;e<appData.player.length;e++){
            if(appData.player[e].multiples>0){
                appData.player[e].timesImg=globalData.fileUrl+"files/images/bull/text_times"+appData.player[e].multiples+".png";
            }
            if(appData.player[e].bankerMultiples>0){
                appData.player[e].bankerTimesImg=globalData.fileUrl+"files/images/bull/text_times"+appData.player[e].bankerMultiples+".png";
            }
            if(appData.player[e].card_type>=1){
                var a=parseInt(appData.player[e].card_type);
                var t=appData.player[e].combo_point;
                if(a>1){
                    t="type"+a;
                } else if(1==a){
                    t="point"+t;
                }
                appData.player[e].bullImg=globalData.fileUrl+"files/images/paijiu/"+t+".png"
            }
            if(4==appData.player[e].account_status){
                if(5==appData.ruleInfo.banker_mode){
                    appData.player[e].robImg=globalData.fileUrl+"files/images/bull/text_notgo.png";
                } else {
                    appData.player[e].robImg=globalData.fileUrl+"files/images/bull/text_notrob.png";
                }
            } else if(5==appData.player[e].account_status){
                if(5==appData.ruleInfo.banker_mode){
                    appData.player[e].robImg=globalData.fileUrl+"files/images/bull/text_go.png";
                } else {
                    appData.player[e].robImg=globalData.fileUrl+"files/images/bull/text_rob.png";
                }
            } else if(6==appData.player[e].account_status){
            } else if(7==appData.player[e].account_status){
                if(0==e){
                    viewMethods.seeMyCard();
                }
            } else if(8==appData.player[e].account_status){
                if(0==e){
                    viewMethods.myCardOver(appData.player[e].is_bull);
                } else {
                    viewMethods.cardOver(appData.player[e].num,appData.player[e].is_bull);
                }
            }
        }
    },
    timeCountDown:function(){
        if(1!=isTimeLimitShow)return appData.game.time<=0?(isTimeLimitShow=!1,0):(isTimeLimitShow=!0,appData.game.time--,void(timeLimit=setTimeout(function(){isTimeLimitShow=!1,viewMethods.timeCountDown()},1e3)))
    },
    clickRobBanker:function(e){
        viewMethods.showRobBankerText();
        socketModule.sendGrabBanker(e);
        if(2==appData.ruleInfo.banker_mode){
            appData.player[0].bankerMultiples=e;
            if(appData.player[0].bankerMultiples>0){
                appData.player[0].bankerTimesImg=globalData.fileUrl+"files/images/bull/text_times"+appData.player[0].bankerMultiples+".png";
            }
        }
        setTimeout(function(){mp3AudioPlay("audioRobBanker")},10)
    },
    showRobBankerText:function(){
        appData.showTimesCoin=!1,appData.showRob=!1,appData.showShowCardButton=!1,appData.showClickShowCard=!1,appData.showNotRobText=!1,appData.showRobText=!0,appData.showBankerCoinText=!1
    },
    showNotRobBankerTextFnc:function(){
        appData.showTimesCoin=!1,appData.showRob=!1,appData.showShowCardButton=!1,appData.showClickShowCard=!1,appData.showNotRobText=!0,appData.showRobText=!1,appData.showBankerCoinText=!1
    },
    clickNotRobBanker:function(){
        viewMethods.showNotRobBankerTextFnc(),socketModule.sendNotGrabBanker(),setTimeout(function(){mp3AudioPlay("audioNoBanker")},10)
    },
    clickSelectTimesCoin:function(e){
        appData.player[0].multiples=e;
        appData.showTimesCoin=!1;
        if(appData.player[0].multiples>0){
            appData.player[0].timesImg=globalData.fileUrl+"files/images/bull/text_times"+appData.player[0].multiples+".png";
        }
        socketModule.sendPlayerMultiples(e);
        setTimeout(function(){mp3AudioPlay("audioTimes"+e)},50);
    },
    clickShowCard:function(){
        appData.showShowCardButton=!1,appData.showClickShowCard=!1,socketModule.sendShowCard()
    },
    clearBanker:function(){
        for(var e=0;e<appData.player.length;e++)
            appData.player[e].is_banker=!1;
        appData.isFinishBankerAnimate=!1;
        var t = 2 * appData.bankerArray.length;
        if(appData.bankerArray.length<6){
            appData.bankerAnimateDuration=parseInt(1500/t);
        }else {
            appData.bankerAnimateDuration=parseInt(2500/t);
        }
    },
    robBankerWithoutAnimate:function(){
        for(var e=0;e<appData.player.length;e++)appData.player[e].account_id==appData.bankerAccountId?(appData.player[e].is_banker=!0,bankerNum=appData.player[e].num):appData.player[e].is_banker=!1,$("#bankerAnimate"+appData.player[e].num).hide(),$("#bankerAnimate1"+appData.player[e].num).hide();setTimeout(function(){appData.game.show_coin=!0,appData.showClockRobText=!1,appData.showClockBetText=!0,appData.isFinishBankerAnimate=!0,viewMethods.resetMyAccountStatus(),viewMethods.updateAllPlayerStatus()},10),appData.game.time=11,appData.game.time>0&&viewMethods.timeCountDown()
    },
    robBankerAnimate:function(e){
        if(5==appData.ruleInfo.banker_mode){
            appData.showRob=!1;
        }
        for(n=0;n<appData.bankerArray.length;n++){
            o="#banker"+appData.bankerArray[n];
            $(o).hide();
        }
        var t = 2 * appData.bankerArray.length;
        if(appData.bankerAnimateCount>=t||appData.bankerAnimateIndex<0||appData.bankerArray.length<2){
            appData.bankerAnimateCount=0,appData.bankerAnimateIndex=-1;o="#banker"+appData.bankerAccountId;$(o).show();for(var a="",n=0;n<appData.player.length;n++)appData.player[n].account_id==appData.bankerAccountId?(appData.player[n].is_banker=!0,a=appData.player[n].num):appData.player[n].is_banker=!1,$("#bankerAnimate"+appData.player[n].num).hide(),$("#bankerAnimate1"+appData.player[n].num).hide();return $(o).hide(),$("#bankerAnimate"+a).css({top:"-0.1vh",left:"-0.1vh",width:"7.46vh",height:"7.46vh"}),$("#bankerAnimate1"+a).css({top:"-1vh",left:"-1vh",width:"9.26vh",height:"9.26vh"}),$("#bankerAnimate"+a).show(),$("#bankerAnimate1"+a).show(),$("#bankerAnimate1"+a).animate({top:"-1vh",left:"-1vh",width:"9.26vh",height:"9.26vh"},400,function(){$("#bankerAnimate1"+a).animate({top:"-0.1vh",left:"-0.1vh",width:"7.46vh",height:"7.46vh"},400,function(){$("#bankerAnimate1"+a).hide()})}),void $("#bankerAnimate"+a).animate({top:"-1.5vh",left:"-1.5vh",width:"10.26vh",height:"10.26vh"},400,function(){$("#bankerAnimate"+a).animate({top:"-0.1vh",left:"-0.1vh",width:"7.46vh",height:"7.46vh"},400,function(){$("#bankerAnimate"+a).hide(),setTimeout(function(){if(console.log("1803: resetMyAccountStatus"),appData.game.show_coin=!0,appData.showClockRobText=!1,appData.showClockBetText=!0,appData.isFinishBankerAnimate=!0,5==appData.ruleInfo.banker_mode){for(var t=0;t<e.data.length;t++)for(var a=0;a<appData.player.length;a++)appData.player[a].account_id==e.data[t].account_id&&(appData.player[a].account_score=e.data[t].account_score);setTimeout(function(){viewMethods.reDeal()},1e3),1!=appData.game.round&&(viewMethods.resetMyAccountStatus(),viewMethods.updateAllPlayerStatus())}else viewMethods.resetMyAccountStatus(),viewMethods.updateAllPlayerStatus()},10),appData.game.time=11,appData.game.time>0&&viewMethods.timeCountDown()})})
        }
        var o="#banker"+appData.bankerArray[appData.bankerAnimateIndex];
        $(o).show();
        appData.lastBankerImgId=o;
        appData.bankerAnimateCount++;
        appData.bankerAnimateIndex++;
        if(appData.bankerAnimateIndex>=appData.bankerArray.length){
            appData.bankerAnimateIndex=0;
        }
        setTimeout(function(){
            viewMethods.robBankerAnimate(e)
        },appData.bankerAnimateDuration);
    },
    showMemberScore:function(e){
        e?($(".memberScoreText1").show(),$(".memberScoreText2").show(),$(".memberScoreText3").show(),$(".memberScoreText4").show(),$(".memberScoreText5").show(),$(".memberScoreText6").show(),$(".memberScoreText7").show(),$(".memberScoreText8").show(),$(".memberScoreText9").show()):($(".memberScoreText1").hide(),$(".memberScoreText2").hide(),$(".memberScoreText3").hide(),$(".memberScoreText4").hide(),$(".memberScoreText5").hide(),$(".memberScoreText6").hide(),$(".memberScoreText7").hide(),$(".memberScoreText8").hide(),$(".memberScoreText9").hide())
    },
    winAnimate:function(e){
        appData.isFinishWinAnimate=!1;
        var t=new Array,a=new Array;
        appData.bankerPlayerNum=appData.bankerPlayer.num;
        if(4==appData.ruleInfo.banker_mode){
            for(n=0;n<e.data.winner_array.length;n++)
                for(o=0;o<appData.player.length;o++)
                    if(e.data.winner_array[n].account_id==appData.player[o].account_id){
                        appData.bankerPlayerNum=appData.player[o].num;
                        t.push(appData.player[o].num);
                    }
        } else {
            for(n=0;n<e.data.winner_array.length;n++)
                for(o=0;o<appData.player.length;o++)
                    if(e.data.winner_array[n].account_id==appData.player[o].account_id){
                        if(appData.player[o].num==appData.bankerPlayer.num){
                            isBankerWin=!0;
                            appData.bankerPlayerNum=appData.player[o].num;
                        } else {
                            t.push(appData.player[o].num);
                        }
                    }
        }
        
        for(n=0;n<e.data.loser_array.length;n++)
            for(o=0;o<appData.player.length;o++)
                if(e.data.loser_array[n].account_id==appData.player[o].account_id&&appData.player[o].num!=appData.bankerPlayerNum){
                    a.push(appData.player[o].num);
                }
        viewMethods.resetCoinsPosition();
        $("#playerCoins").show();
        for(n=1;n<10;n++)
            viewMethods.showCoins(n,!1);
        for(n=0;n<t.length;n++)
            for(o=0;o<8;o++)
                $(".memberCoin"+t[n]+o).css(memCoin[appData.bankerPlayerNum]);
                
        for(n=0;n<a.length;n++)
            viewMethods.showCoins(a[n],!0);

        for(var n=0;n<a.length;n++){
            for(var o=0;o<8;o++)
                $(".memberCoin"+a[n]+o).animate(memCoin[appData.bankerPlayerNum],150+150*o);
            setTimeout(function(){
                mp3AudioPlay("audioCoin")
            },10);
        }
        var i=100,r=100;
        if(a.length>=1){
            i=1800;
            r=t.length>=1?3600:1800;
        } else {
            if(t.length>=1){
                r=1800;
            }
        }

        4==ruleInfo.banker_mode&&(r=1800,i=1800);
        if(t.length>=1){
            setTimeout(function(){
                for(e=0;e<a.length;e++)
                    viewMethods.showCoins(a[e],!1);
                for(e=0;e<t.length;e++)
                    viewMethods.showCoins(t[e],!0);
                for(var e=0;e<t.length;e++)
                    for(var n=0;n<8;n++)
                        $(".memberCoin"+t[e]+n).animate(memCoin[t[e]],150+150*n);
                setTimeout(function(){
                    mp3AudioPlay("audioCoin");
                },10);
            },i);
        }
        setTimeout(function(){
            viewMethods.finishWinAnimate(e)
        },r);
    },
    finishWinAnimate:function(e){
        $("#playerCoins").hide();
        appData.game.show_card=!1;
        appData.game.show_score=!0;
        $(".memberScoreText1").fadeIn(200);
        $(".memberScoreText2").fadeIn(200);
        $(".memberScoreText3").fadeIn(200);
        $(".memberScoreText4").fadeIn(200);
        $(".memberScoreText5").fadeIn(200);
        $(".memberScoreText6").fadeIn(200);
        $(".memberScoreText7").fadeIn(200);
        $(".memberScoreText8").fadeIn(200);
        $(".memberScoreText9").fadeIn(200,function(){
            if(5==appData.ruleInfo.banker_mode){
                if(1!=appData.isBreak)
                    viewMethods.gameOverNew(e.data.score_board,e.data.balance_scoreboard);
                else 
                    for(var t=0;t<9;t++)
                        for(s in e.data.score_board)
                            appData.player[t].account_id==s&&(appData.player[t].account_score=Math.ceil(e.data.score_board[s]));
            } else {
                viewMethods.gameOverNew(e.data.score_board,e.data.balance_scoreboard);
            }

            setTimeout(function(){
                $(".memberScoreText1").fadeOut("slow");
                $(".memberScoreText2").fadeOut("slow");
                $(".memberScoreText3").fadeOut("slow");
                $(".memberScoreText4").fadeOut("slow");
                $(".memberScoreText5").fadeOut("slow");
                $(".memberScoreText6").fadeOut("slow");
                $(".memberScoreText7").fadeOut("slow");
                $(".memberScoreText8").fadeOut("slow");
                $(".memberScoreText9").fadeOut("slow");
                if(5==appData.ruleInfo.banker_mode&&1==appData.isBreak){
                    appData.overType=2;
                    setTimeout(function(){
                        viewMethods.clickShowAlert(9,"庄家分数不足，提前下庄，点击确定查看结算")
                    },1e3);
                } else {

                }
                for(var e=0;e<9;e++){
                    if(appData.player[e].account_status>=6&&5!=ruleInfo.banker_mode){
                        appData.player[e].is_banker=!1;
                        if(appData.player[e].account_id==appData.bankerID){
                            appData.player[e].is_banker=!0;
                        }
                    }
                    if(2!=appData.player[e].account_status&&0!=appData.player[e].account_status){
                        appData.player[e].account_status=1;
                    }
                }
            },2e3);
            appData.isFinishWinAnimate=!0;
            if(5!=appData.ruleInfo.banker_mode){
                e.data.total_num==e.data.game_num&&setTimeout(function(){viewMethods.roundEnd(),newNum=e.data.room_number},1e3);
            } else {
                if(1==appData.isBreak){

                } else if(e.data.total_num==e.data.game_num){
                    setTimeout(function(){
                        viewMethods.roundEnd();
                        newNum=e.data.room_number;
                    },1e3);
                }
            }
        });
    },
    resetCoinsPosition:function(){
        for(var e=1;e<10;e++)
            for(var t=0;t<8;t++)
                $(".memberCoin"+e+t).css(memCoin[e]);
    },
    showCoins:function(e,t){
        if(t)for(a=0;a<8;a++)$(".memberCoin"+e+a).show();else for(var a=0;a<8;a++)$(".memberCoin"+e+a).hide()
    },
    showQRCode:function(){}
};
var fileDealerNum="d_30";
var width=window.innerWidth;
var height=window.innerHeight;
var numD=0;
var isTimeLimitShow=!1;
var isBankerWin=!1;
var timesOffset=(.9*width-.088*height*4-.02*width*3)/2;
var coinLeft1=.045*height+"px";
var coinLeft2=width-.06*height+"px";
var coinLeft3=width-.06*height+"px";
var coinLeft4=width-.06*height+"px";
var coinLeft5=width-.18*height+"px";
var coinLeft6=.15*height+"px";
var coinLeft7=.045*height+"px";
var coinLeft8=.045*height+"px";
var coinLeft9=.045*height+"px";

var memCoin = [
    {},
    {top: '82%', left: '4.5vh'},
    {top: '59%', left: coinLeft2},
    {top: '43%', left: coinLeft2},
    {top: '27%', left: coinLeft2},
    {top: '6%',  left: coinLeft5},
    {top: '6%',  left: '15vh'},
    {top: '27%', left: '4.5vh'},
    {top: '43%', left: '4.5vh'},
    {top: '59%', left: '4.5vh'},
    ];

var viewStyle={
    readyButton:{position:"absolute",top:(.11*height-.0495*height)/2+"px",left:"31vw",width:"28vw",height:"9vw"},
    readyText:{position:"absolute",top:"50%",left:"50%",width:"6vh",height:"3vh","margin-top":"-1.5vh","margin-left":"-3vh"},
    button:{position:"absolute",top:"68%",left:"5%",width:"90%",height:"11vh",overflow:"hidden"},
    rob:{position:"absolute",top:(.11*height-.0495*height)/2+"px",left:(.9*width-.0495*height/.375*2-20)/2+"px",width:.0495*height/.375+"px",height:.0495*height+"px"},
    rob1:{position:"absolute",top:"0px",left:"0px",width:.0495*height/.375+"px",height:.0495*height+"px","line-height":.0495*height+"px","text-align":"center",color:"white","font-size":"2.2vh","font-weight":"bold"},
    notRob:{position:"absolute",top:(.11*height-.0495*height)/2+"px",left:(.9*width-.0495*height/.375*2-20)/2+.0495*height/.375+20+"px",width:.0495*height/.375+"px",height:.0495*height+"px"},
    notRob1:{position:"absolute",top:"0px",left:"0px",width:.0495*height/.375+"px",height:.0495*height+"px","line-height":.0495*height+"px","text-align":"center",color:"white","font-size":"2.2vh","font-weight":"bold"},
    showCard:{position:"absolute",top:(.11*height-.0495*height)/2+"px",left:(.9*width-.0495*height/.375)/2+"px",width:.0495*height/.375+"px",height:.0495*height+"px"},
    showCard1:{position:"absolute",top:"0px",left:"0px",width:.0495*height/.375+"px",height:.0495*height+"px","line-height":.0495*height+"px","text-align":"center",color:"white","font-size":"2.2vh","font-weight":"bold"},
    times1:{position:"absolute",top:(.11*height-.088*height/2)/2+"px",left:timesOffset+"px",width:.088*height+"px",height:.088*height/2+"px","line-height":.088*height/2+"px"},
    timesText:{position:"absolute",width:.088*height+"px",height:.088*height/2+"px","line-height":.088*height/2+"px","text-align":"center",color:"white","font-size":"2.2vh","font-weight":"bold"},
    times2:{position:"absolute",top:(.11*height-.088*height/2)/2+"px",left:timesOffset+.02*width+.088*height+"px",width:.088*height+"px",height:.088*height/2+"px","line-height":.088*height/2+"px"},
    times3:{position:"absolute",top:(.11*height-.088*height/2)/2+"px",left:timesOffset+.02*width*2+.088*height*2+"px",width:.088*height+"px",height:.088*height/2+"px","line-height":.088*height/2+"px"},
    times4:{position:"absolute",top:(.11*height-.088*height/2)/2+"px",left:timesOffset+.02*width*3+.088*height*3+"px",width:.088*height+"px",height:.088*height/2+"px","line-height":.088*height/2+"px"},
    robText2:{position:"absolute",top:(.11*height-.03*height)/2+"px",left:(.9*width-.0557*height-.03*height-.005*height)/2+"px",width:.0557*height+"px",height:.03*height+"px"},
    robText:{position:"absolute",top:(.11*height-.03*height)/2+"px",left:(.9*width-.0557*height)/2+"px",width:.0557*height+"px",height:.03*height+"px"},
    robTimesText:{position:"absolute",top:(.11*height-.03*height)/2+"px",left:(.9*width-.0557*height-.03*height-.002*height)/2+.0557*height+.005*height+"px",width:.03*height+"px",height:.03*height+"px"},
    notRobText:{position:"absolute",top:(.11*height-.03*height)/2+"px",left:(.9*width-.0557*height)/2+"px",width:.0557*height+"px",height:.03*height+"px"},
    showCardText:{position:"absolute",top:"10%",left:"10%",width:"80%",height:"11vh","font-size":"2.2vh"},
    showCardText1:{position:"absolute",width:"100%",height:"100%",color:"white","font-size":"2.2vh","text-align":"center","line-height":"11vh","font-family":"Helvetica 微软雅黑"},
    coinText:{position:"absolute",top:"10%",left:"10%",width:"80%",height:"11vh","font-size":"2.2vh"},
    coinText1:{position:"absolute",width:"100%",height:"100%",color:"white","font-size":"2.2vh","text-align":"center","line-height":"11vh","font-family":"Helvetica 微软雅黑"}
};
var createInfo={
    type:-1,
    isShow:!1,
    isShowRule:!1,
    baseScore:3,
    timesType:1,
    isCardfive:0,
    isCardbomb:0,
    isCardtiny:0,
    ticket:1,
    rule_height:"4vh",
    banker_mode:1,
    banker_score:4,
    banker1:"selected",
    banker2:"unselected",
    banker3:"unselected",
    banker4:"unselected",
    banker5:"unselected"
};
var ruleInfo={
    type:-1,
    isShow:!1,
    isShowRule:!1,
    baseScore:1,
    timesType:1,
    isCardfive:0,
    isCardbomb:0,
    isCardtiny:0,
    ticket:1,
    rule_height:"4vh",
    banker_mode:1,
    banker_score:1,
    bankerText:"抢庄"
};
var editAudioInfo={
    isShow:!1,
    backMusic:1,
    messageMusic:1
};
var audioInfo={
    backMusic:1,
    messageMusic:1
};
localStorage.backMusic?(editAudioInfo.backMusic=localStorage.backMusic,
        audioInfo.backMusic=localStorage.backMusic):localStorage.backMusic=1,localStorage.messageMusic?(editAudioInfo.messageMusic=localStorage.messageMusic,audioInfo.messageMusic=localStorage.messageMusic):localStorage.messageMusic=1;
var appData={
    user_id:userData.id,
    dealerName:globalData.dealerName,
    viewStyle:viewStyle,
    roomStatus:globalData.roomStatus,
    isAA:!1,
    isAutoActive:!1,
    isShop:globalData.isShop,
    width:window.innerWidth,
    height:window.innerHeight,
    roomCard:Math.ceil(globalData.card),
    is_connect:!1,
    player:[],
    scoreboard:"",
    activity:[],
    isShowInvite:!1,
    isShowAlert:!1,
    isShowShop:!1,
    isShowMessage:!1,
    alertType:0,
    alertText:"",
    showRob:!1,
    showShowCardButton:!1,
    showRobText:!1,
    showNotRobText:!1,
    showClockRobText:!1,
    showClockBetText:!1,
    showClockShowCard:!1,
    showTimesCoin:!1,
    showClickShowCard:!1,
    showBankerCoinText:!1,
    clickCard4:!1,
    base_score:0,
    playerBoard:{
        score:new Array,
        round:0,
        record:""
    },
    game:game,
    roomCardInfo:[],
    wsocket:ws,
    connectOrNot:!0,
    socketStatus:0,
    heartbeat:null,
    select:1,
    ticket_count:0,
    isDealing:!1,
    message:message,
    isShowShopLoading:!1,
    bankerArray:[],
    bankerAccountId:"",
    bankerPlayer:"",
    bankerPlayerNum:-1,
    bankerAnimateCount:0,
    bankerAnimateIndex:0,
    lastBankerImgId:"",
    bankerAnimateDuration:120,
    isFinishWinAnimate:!1,
    isFinishBankerAnimate:!1,
    isShowErweima:!1,
    createInfo:createInfo,
    isShowRecord:!1,
    recordList:[],
    ruleInfo:ruleInfo,
    canBreak:0,
    overType:1,
    isBreak:0,
    breakData:"",
    bankerID:0,
    editAudioInfo:editAudioInfo,
    audioInfo:audioInfo,
    isReconnect:!0,
    bScroll:null,
    isShowNoteImg:!1,

    //广播
    isShowNoty : false,
    notyMsg   : ''
};

    //广播
    setTimeout(function () {
        if (globalData.isNotyMsg != undefined && globalData.isNotyMsg != null) {
            appData.notyMsg = globalData.notyMsg;
            if (globalData.isNotyMsg == 1) {
                appData.isShowNoty = true;
                setTimeout(function () {
                    appData.isShowNoty = false;
                }, globalData.notyTime * 1000);
            }
        } else {
            globalData.isNotyMsg = 0;
        }

        $('#marquee').marquee({
            //speed in milliseconds of the marquee
            duration: globalData.notySpeed,
            //gap in pixels between the tickers
            gap: 400,
            //time in milliseconds before the marquee will start animating
            delayBeforeStart: 0,
            //'left' or 'right'
            direction: 'left',
            //true or false - should the marquee be duplicated to show an effect of continues flow
            duplicated: true
        });

    }, 50);
    //end 广播

var resetState=function(){
    appData.game.show_score=!1;
    appData.game.show_bettext=!1;
    appData.clickCard4=!1;
    for(e=0;e<9;e++){
        appData.player.push({
            num:e+1,
            serial_num:e+1,
            account_id:0,
            account_code:"",
            account_status:0,
            playing_status:0,
            online_status:0,
            nickname:"",
            headimgurl:"",
            account_score:0,
            ticket_checked:1,
            is_win:!1,
            win_type:0,
            limit_time:0,
            is_operation:!1,
            win_show:!1,
            card:[],
            card_open:[],
            is_showCard:!1,
            is_pk:!1,
            is_readyPK:!1,
            card_type:0,
            is_banker:!1,
            multiples:0,
            bankerMultiples:0,
            combo_point:0,
            timesImg:"",
            bankerTimesImg:"",
            robImg:"",
            bullImg:"",
            single_score:0,
            messageOn:!1,
            is_bull:!1,
            is_showbull:!1,
            is_audiobull:!1,
            is_showCard:!1,
            messageText:"",
            coins:[]
        });
        appData.playerBoard.score.push({
            account_id:0,
            nickname:"",
            account_score:0,
            isBigWinner:0
        });
    }
    for(var e=0;e<appData.player.length;e++){
        appData.player[e].coins=[];
        for(var t=0;t<=7;t++)
            appData.player[e].coins.push("memberCoin"+appData.player[e].num+t);
    }
    if(1!=globalData.isAlertMsg){
        httpModule.getManageInfo();
    }
};
var resetAllPlayerData=function(){
    appData.player=[];
    for(e=0;e<9;e++)appData.player.push({num:e+1,serial_num:e+1,account_id:0,account_status:0,playing_status:0,online_status:0,nickname:"",headimgurl:"",account_code:"",account_score:0,ticket_checked:0,is_win:!1,win_type:0,limit_time:0,is_operation:!1,win_show:!1,card:new Array,card_open:new Array,is_showCard:!1,is_pk:!1,is_readyPK:!1,card_type:0,is_banker:!1,multiples:0,bankerMultiples:0,combo_point:0,timesImg:"",bankerTimesImg:"",robImg:"",bullImg:"",single_score:0,messageOn:!1,is_bull:!1,is_showbull:!1,is_audiobull:!1,messageText:"我们来血拼吧",coins:[]});for(var e=0;e<appData.player.length;e++){appData.player[e].coins=[];for(var t=0;t<=7;t++)appData.player[e].coins.push("memberCoin"+appData.player[e].num+t)}
};
var newGame=function(){
    appData.playerBoard={score:new Array,round:0,record:""},appData.game.round=0,appData.game.status=1,appData.game.score=0,appData.game.currentScore=0,appData.game.cardDeal=0,appData.game.can_open=0,appData.game.current_win=0,appData.game.is_play=!1,appData.game.show_score=!1,appData.game.show_bettext=!1,appData.clickCard4=!1;for(var e=0;e<appData.player.length;e++)appData.playerBoard.score.push({account_id:0,nickname:"",account_score:0,isBigWinner:0}),1==appData.player[e].online_status?(appData.player[e].account_status=0,appData.player[e].playing_status=0,appData.player[e].is_win=!1,appData.player[e].is_operation=!1,appData.player[e].win_type=0,appData.player[e].win_show=!1,appData.player[e].card=new Array,appData.player[e].card_open=new Array,appData.player[e].card_type=0,appData.player[e].ticket_checked=0,appData.player[e].account_score=0,appData.player[e].is_showCard=!1,appData.player[e].is_readyPK=!1,appData.player[e].is_pk=!1,appData.player[e].is_banker=!1,appData.player[e].multiples=0,appData.player[e].bankerMultiples=0,appData.player[e].combo_point=0,appData.player[e].timesImg="",appData.player[e].bankerTimesImg="",appData.player[e].robImg="",appData.player[e].bullImg="",appData.player[e].single_score=0,appData.player[e].num=e+1,appData.player[e].is_bull=!1,appData.player[e].is_showbull=!1,appData.player[e].is_audiobull=!1):appData.player[e]={num:e+1,serial_num:appData.player[e].serial_num,account_id:0,account_status:0,playing_status:0,online_status:0,nickname:"",headimgurl:"",account_score:0,is_win:!1,win_type:0,ticket_checked:0,limit_time:0,is_operation:!1,win_show:!1,card:new Array,card_open:new Array,is_showCard:!1,is_pk:!1,is_readyPK:!1,card_type:0,is_banker:!1,multiples:0,bankerMultiples:0,combo_point:0,timesImg:"",bankerTimesImg:"",robImg:"",bullImg:"",single_score:0,is_bull:!1,is_showbull:!1,is_audiobull:!1}
};
var connectSocket=function(e,t,a,n,o){
    (ws=new WebSocket(e)).onopen=t,ws.onmessage=a,ws.onclose=n,ws.onerror=o
};
var wsOpenCallback=function(e){logMessage("websocket is opened"),appData.connectOrNot=!0,appData.heartbeat&&clearInterval(appData.heartbeat),appData.heartbeat=setInterval(function(){appData.socketStatus=appData.socketStatus+1,appData.socketStatus>1&&(appData.connectOrNot=!1),appData.socketStatus>4&&appData.isReconnect&&reload(),ws.readyState==WebSocket.OPEN&&ws.send("@")},3e3),socketModule.sendPrepareJoinRoom()};
var wsMessageCallback=function wsMessageCallback(evt){
    if(appData.connectOrNot=!0,"@"==evt.data)
        return appData.socketStatus=0,0;
    var obj=eval("("+evt.data+")");
    if(-201==obj.result){
        viewMethods.clickShowAlert(31,obj.result_message);
    } else if(-202==obj.result){
        appData.isReconnect=!1,socketModule.closeSocket(),viewMethods.clickShowAlert(32,obj.result_message);
    } else if(-203==obj.result){
        methods.reloadView();
    }

    if(0!=obj.result){
        obj.operation==wsOperation.JoinRoom?
                1==obj.result?
                1==obj.data.alert_type?
                viewMethods.clickShowAlert(1,obj.result_message):
                2==obj.data.alert_type?
                viewMethods.clickShowAlert(2,obj.result_message):
                3==obj.data.alert_type?
                viewMethods.clickShowAlert(11,obj.result_message):
                viewMethods.clickShowAlert(7,obj.result_message):
                (obj.result,viewMethods.clickShowAlert(7,obj.result_message)):
                obj.operation==wsOperation.ReadyStart?
                1==obj.result&&viewMethods.clickShowAlert(1,obj.result_message):
                obj.operation==wsOperation.PrepareJoinRoom?
                (obj.result>0&&socketModule.processGameRule(obj),1==obj.result?
                    1==obj.data.alert_type?viewMethods.clickShowAlert(1,obj.result_message):
                    2==obj.data.alert_type?viewMethods.clickShowAlert(2,obj.result_message):
                    3==obj.data.alert_type?viewMethods.clickShowAlert(11,obj.result_message):
                    viewMethods.clickShowAlert(7,obj.result_message):
                    (obj.result,viewMethods.clickShowAlert(7,obj.result_message))):
                obj.operation==wsOperation.ActiveRoom?
                1==obj.result?viewMethods.clickShowAlert(1,obj.result_message):
                socketModule.sendPrepareJoinRoom():
                obj.operation==wsOperation.CreateRoom?
                -1==obj.result?reload():1==obj.result&&viewMethods.clickShowAlert(1,obj.result_message):
                obj.operation==wsOperation.RefreshRoom&&reload(),appData.player[0].is_operation=!1;
    } else {
        obj.operation==wsOperation.PrepareJoinRoom?socketModule.processPrepareJoinRoom(obj):
        obj.operation==wsOperation.GameHistory?socketModule.processGameHistory(obj):
        obj.operation==wsOperation.JoinRoom?socketModule.processJoinRoom(obj):
        obj.operation==wsOperation.ActiveRoom?socketModule.processActiveRoom(obj):
        obj.operation==wsOperation.RefreshRoom?socketModule.processRefreshRoom(obj):
        obj.operation==wsOperation.AllGamerInfo?socketModule.processAllGamerInfo(obj):
        obj.operation==wsOperation.UpdateGamerInfo?socketModule.processUpdateGamerInfo(obj):
        obj.operation==wsOperation.UpdateAccountStatus?socketModule.processUpdateAccountStatus(obj):
        obj.operation==wsOperation.UpdateAccountShow?socketModule.processUpdateAccountShow(obj):
        obj.operation==wsOperation.UpdateAccountMultiples?socketModule.processUpdateAccountMultiples(obj):
        obj.operation==wsOperation.StartLimitTime?socketModule.processStartLimitTime(obj):
        obj.operation==wsOperation.CancelStartLimitTime?socketModule.processCancelStartLimitTime(obj):
        obj.operation==wsOperation.GameStart?socketModule.processGameStart(obj):
        obj.operation==wsOperation.NotyChooseChip?socketModule.processNotyChooseChip(obj):
        obj.operation==wsOperation.UpdateAccountScore?socketModule.processUpdateAccountScore(obj):
        obj.operation==wsOperation.OpenCard?socketModule.processOpenCard(obj):
        obj.operation==wsOperation.Win?socketModule.processWin(obj):
        obj.operation==wsOperation.Discard?socketModule.processDiscard(obj):
        obj.operation==wsOperation.BroadcastVoice?socketModule.processBroadcastVoice(obj):
        obj.operation==wsOperation.CreateRoom?socketModule.processCreateRoom(obj):
        obj.operation==wsOperation.StartBet?socketModule.processStartBet(obj):
        obj.operation==wsOperation.StartShow?socketModule.processStartShow(obj):
        obj.operation==wsOperation.MyCards?socketModule.processMyCards(obj):
        obj.operation==wsOperation.BreakRoom?socketModule.processBreakRoom(obj):
        logMessage(obj.operation)
    }
};
var wsCloseCallback=function(e){logMessage("websocket closed："),logMessage(e),appData.connectOrNot=!1,reconnectSocket()};
var wsErrorCallback=function(e){logMessage("websocket onerror："),logMessage(e)};
var reconnectSocket=function(){
    if(appData.isReconnect&&4!=globalData.roomStatus){if(ws){if(logMessage(ws.readyState),1==ws.readyState)return;ws=null}logMessage("reconnectSocket"),connectSocket(globalData.socket,wsOpenCallback,wsMessageCallback,wsCloseCallback,wsErrorCallback)}};
    var m4aAudioPlay=function(e){if(!audioModule.audioOn)return 0;audioModule.playSound(e)};
    var mp3AudioPlay=function(e){if(!audioModule.audioOn)return 0;audioModule.playSound(e)};
    var audioModule={
        audioOn:!1,
        audioContext:null,
        audioBuffers:[],
        baseUrl:"",
        initModule:function(e){
            this.baseUrl=e,this.audioBuffers=[],window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext,this.audioContext=new window.AudioContext
        },
        stopSound:function(e){var t=this.audioBuffers[e];t&&t.source&&(t.source.stop(0),t.source=null)},
        playSound:function(e,t){if("backMusic"==e){if(0==audioInfo.backMusic)return}else if(0==audioInfo.messageMusic)return;var a=this.audioBuffers[e];if(a)try{void 0!=WeixinJSBridge&&WeixinJSBridge.invoke("getNetworkType",{},function(e){a.source=null,a.source=audioModule.audioContext.createBufferSource(),a.source.buffer=a.buffer,a.source.loop=!1;var n=audioModule.audioContext.createGain();1==t?(a.source.loop=!0,n.gain.value=.7):n.gain.value=1,a.source.connect(n),n.connect(audioModule.audioContext.destination),a.source.start(0)})}catch(e){}},
        initSound:function(e,t){this.audioContext.decodeAudioData(e,function(e){audioModule.audioBuffers[t]={name:t,buffer:e,source:null},"backMusic"==t&&(audioModule.audioOn=!0,audioModule.playSound(t,!0))},function(e){logMessage("Error decoding file",e)})},
        loadAudioFile:function(e,t){var a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType="arraybuffer",a.onload=function(e){audioModule.initSound(a.response,t)},a.send()},
        loadAllAudioFile:function(){
            if(4!=globalData.roomStatus&&1!=isLoadAudioFile){
                isLoadAudioFile=!0;
                this.loadAudioFile(this.baseUrl+"files/audio/paijiu/background3.mp3","backMusic");
                var e=["robn.m4a","rob.m4a","point0.m4a","point1.m4a","point2.m4a","point3.m4a","point4.m4a","point5.m4a","point6.m4a","point7.m4a","point8.m4a","point9.m4a","type2.m4a","type3.m4a","type4.m4a","type5.m4a","type6.m4a","type7.m4a","type8.m4a","type9.m4a","type10.m4a","type11.m4a","type12.m4a","type13.m4a","type14.m4a","type15.m4a","type16.m4a","type17.m4a","type18.m4a","type19.m4a","type20.m4a","type21.m4a","type22.m4a","type23.m4a","time1.m4a","time2.m4a","time3.m4a","time4.m4a","time8.m4a","time5.m4a","coin.mp3","audio1.m4a"];
                var t=["audioNoBanker","audioRobBanker","point0","point1","point2","point3","point4","point5","point6","point7","point8","point9","type2","type3","type4","type5","type6","type7","type8","type9","type10","type11","type12","type13","type14","type15","type16","type17","type18","type19","type20","type21","type22","type23","audioTimes1","audioTimes2","audioTimes3","audioTimes4","audioTimes8","audioTimes5","audioCoin","audio1"];
                for(a=0;a<e.length;a++)
                    this.loadAudioFile(this.baseUrl+"files/audio/paijiu/"+e[a],t[a]);
                var n=["message9.m4a","message10.m4a","message11.m4a","message1.m4a","message2.m4a","message3.m4a","message4.m4a","message12.m4a","message6.m4a","message7.m4a","message8.m4a"];
                o=["message0","message1","message2","message3","message4","message5","message6","message7","message8","message9","message10"];
                for(a=0;a<n.length;a++)
                    this.loadAudioFile(this.baseUrl+"files/audio/sound/"+n[a],o[a]);
            }
        }
    };
    audioModule.initModule(globalData.fileUrl);
    var initView=function(){$("#app-main").width(appData.width),$("#app-main").height(appData.height),$("#table").width(appData.width),$("#table").height(appData.height),$(".ranking").css("width",2*appData.width),$(".ranking").css("height",2*appData.width*1.621),window.onload=function(){for(var e=["table","vinvite","valert","vmessage","vshop","vcreateRoom","vroomRule","endCreateRoom","endCreateRoomBtn"],t=e.length,a=0;a<t;a++){var n=document.getElementById(e[a]);n&&n.addEventListener("touchmove",function(e){e.preventDefault()},!1)}}};
    var methods={
        clickGameOver:viewMethods.clickGameOver,
        showInvite:viewMethods.clickShowInvite,
        showAlert:viewMethods.clickShowAlert,
        showMessage:viewMethods.showMessage,
        closeInvite:viewMethods.clickCloseInvite,
        closeAlert:viewMethods.clickCloseAlert,
        createRoom:viewMethods.clickCreateRoom,
        sitDown:viewMethods.clickSitDown,
        getCards:viewMethods.clickGetCards,
        seeMyCard4:viewMethods.seeMyCard4,
        imReady:viewMethods.clickReady,
        imCloseRoom:viewMethods.clickCloseRoom,
        robBanker:viewMethods.clickRobBanker,
        showCard:viewMethods.clickShowCard,
        selectTimesCoin:viewMethods.clickSelectTimesCoin,
        hideMessage:viewMethods.hideMessage,
        closeEnd:viewMethods.closeEnd,
        messageOn:viewMethods.messageOn,
        hall: function(){
            window.location.href = globalData.hallPath;
        },
        notRobBanker:viewMethods.clickNotRobBanker,
        showGameRule:function(){4!=appData.roomStatus&&($(".createRoom .mainPart").css("height","60vh"),$(".createRoom .mainPart .blueBack").css("height","51vh"),appData.ruleInfo.isShowRule=!0)},
        cancelGameRule:function(){appData.ruleInfo.isShowRule=!1,$(".createRoom .mainPart").css("height","65vh"),$(".createRoom .mainPart .blueBack").css("height","46vh")},
        showGameHistory:function(){socketModule.sendGameHistory()},
        closeRecord:function(){appData.isShowRecord=!1},
        showBreakRoom:function(){null!=appData.breakData&&void 0!=appData.breakData&&viewMethods.gameOverNew(appData.breakData.data.score_board,appData.breakData.data.balance_scoreboard),chooseBigWinner(),$(".ranking .rankBack").css("opacity","1"),$(".roundEndShow").show(),$(".ranking").show(),canvas()},
        confirmBreakRoom:function(){socketModule.sendGameOver(),viewMethods.clickCloseAlert()},
        showQRCode:viewMethods.showQRCode,
        closeErweima:function(){},
        showAudioSetting:function(){appData.editAudioInfo.backMusic=appData.audioInfo.backMusic,appData.editAudioInfo.messageMusic=appData.audioInfo.messageMusic,appData.editAudioInfo.isShow=!0},
        cancelAudioSetting:function(){appData.editAudioInfo.isShow=!1},
        confirmAudioSetting:function(){appData.editAudioInfo.isShow=!1,appData.audioInfo.backMusic=appData.editAudioInfo.backMusic,appData.audioInfo.messageMusic=appData.editAudioInfo.messageMusic,localStorage.backMusic=appData.editAudioInfo.backMusic,localStorage.messageMusic=appData.editAudioInfo.messageMusic,1==appData.audioInfo.backMusic?(audioModule.stopSound("backMusic"),audioModule.playSound("backMusic",!0)):audioModule.stopSound("backMusic")},
        setBackMusic:function(){0==appData.editAudioInfo.backMusic?appData.editAudioInfo.backMusic=1:appData.editAudioInfo.backMusic=0},
        setMessageMusic:function(){0==appData.editAudioInfo.messageMusic?appData.editAudioInfo.messageMusic=1:appData.editAudioInfo.messageMusic=0},
        testRefreshRoom:function(){socketModule.sendRefreshRoom()},
        reloadView:function(){reload()},
        confirmMessage:function(){
            appData.isShowAlert=!1;
            httpModule.callbackMessage();
            httpModule.getManageInfo();
        },
        personInfo:function(){window.location.href=globalData.hpUrl},
        showNoteImg:function(){appData.isShowNoteImg=!0},
        hideNoteImg:function(){appData.isShowNoteImg=!1}
    };


var vueLife={
    vmCreated:function(){
        logMessage("vmCreated"),resetState(),initView(),4!=globalData.roomStatus&&$("#loading").hide(),$(".main").show()
    },
    vmUpdated:function(){
        logMessage("vmUpdated")
    },
    vmMounted:function(){
        logMessage("vmMounted"),$("#marquee").marquee({duration:globalData.notySpeed,gap:50,delayBeforeStart:0,direction:"left",duplicated:!0})
    },
    vmDestroyed:function(){
        logMessage("vmDestroyed")
    }
};
var vm=new Vue({
    el:"#app-main",
    data:appData,
    methods:methods,
    created:vueLife.vmCreated,
    updated:vueLife.vmUpdated,
    mounted:vueLife.vmMounted,
    destroyed:vueLife.vmDestroyed
});
var wsctop=0;
var shareContent="";
var wxModule={
    config:function(){
    wx.config({
        debug:!1,
        appId:configData.appId,
        timestamp:configData.timestamp,
        nonceStr:configData.nonceStr,
        signature:configData.signature,
        jsApiList:["onMenuShareTimeline",
        "onMenuShareAppMessage",
        "hideMenuItems"]
    });
    getShareContent();
    wx.onMenuShareTimeline({
        title:globalData.shareTitle,
        desc:shareContent,
        link:globalData.roomUrl,
        imgUrl:globalData.fileUrl+"files/images/paijiu/share_icon.png",
        success:function(){},
        cancel:function(){}
    });
    wx.onMenuShareAppMessage({
        title:globalData.shareTitle,
        desc:shareContent,
        link:globalData.roomUrl,
        imgUrl:globalData.fileUrl+"files/images/paijiu/share_icon.png",
        success:function(){},
        cancel:function(){}})
}};
wx.config({
    debug:!1,
    appId:configData.appId,
    timestamp:configData.timestamp,
    nonceStr:configData.nonceStr,
    signature:configData.signature,
    jsApiList:["onMenuShareTimeline",
    "onMenuShareAppMessage",
    "hideMenuItems"]
});
var isLoadAudioFile=!1;
wx.ready(function(){
    audioModule.loadAllAudioFile();
    wx.hideMenuItems({
        menuList:["menuItem:copyUrl","menuItem:share:qq","menuItem:share:weiboApp","menuItem:favorite","menuItem:share:facebook","menuItem:share:QZone","menuItem:refresh"]
    });
    getShareContent();
    wx.onMenuShareTimeline({
        title:globalData.shareTitle,
        desc:shareContent,
        link:globalData.roomUrl,
        imgUrl:globalData.fileUrl+"files/images/paijiu/share_icon.png",
        success:function(){},
        cancel:function(){}});
    wx.onMenuShareAppMessage({
        title:globalData.shareTitle,
        desc:shareContent,
        link:globalData.roomUrl,
        imgUrl:globalData.fileUrl+"files/images/paijiu/share_icon.png",
        success:function(){},
        cancel:function(){}})
});
wx.error(function(e){});

function logMessage(e){console.log(e)}

function reload(e){globalData.isShortUrl?window.location.href=window.location.href+"/"+1e4*Math.random():window.location.href=window.location.href+"&id="+1e4*Math.random()}

function chooseBigWinner() {
    
        //对积分榜排序
        appData.playerBoard.score.sort(function(a,b){
            return b.account_score - a.account_score;
        });   
    
        var length = appData.playerBoard.score.length;
        var maxScore = 1;
        for (var i = 0; i < length; i++) {
            appData.playerBoard.score.isBigWinner = 0;
            if (appData.playerBoard.score[i].account_score > maxScore) {
                maxScore = appData.playerBoard.score[i].account_score;
            }
        }
    
        for (var j = 0; j < length; j++) {
            if (appData.playerBoard.score[j].account_score == maxScore) {
                appData.playerBoard.score[j].isBigWinner = 1;
            }
        }
    
    };

function getShareContent(){shareContent="\n",1==appData.ruleInfo.banker_mode?shareContent+="模式：自由抢庄 ":2==appData.ruleInfo.banker_mode?shareContent+="模式：明牌抢庄 ":3==appData.ruleInfo.banker_mode?shareContent+="模式：牛牛上庄 ":4==appData.ruleInfo.banker_mode?shareContent+="模式：通比牛牛 ":5==appData.ruleInfo.banker_mode&&(shareContent+="模式：固定庄家 "),1==appData.ruleInfo.baseScore?shareContent+="底分：1分":2==appData.ruleInfo.baseScore?shareContent+="底分：3分":3==appData.ruleInfo.baseScore?shareContent+="底分：5分":4==appData.ruleInfo.baseScore?shareContent+="底分：10分":5==appData.ruleInfo.baseScore?shareContent+="底分：20分":6==appData.ruleInfo.baseScore?shareContent+="底分：2分":7==appData.ruleInfo.baseScore&&(shareContent+="底分：4分"),2==appData.ruleInfo.timesType&&(shareContent+="  规则：至尊10倍，双天双地双人8倍，对子6倍，天王地王5倍，天杠地杠天高九地高九4倍，九点3倍，八点2倍"),1==appData.ruleInfo.ticket?shareContent+="  局数：12局x2张房卡":shareContent+="  局数：24局x4张房卡"}

function canvas(){var e=document.getElementById("ranking");html2canvas(e,{allowTaint:!0,taintTest:!1,onrendered:function(e){e.id="mycanvas";var t=e.toDataURL("image/jpeg",.5);$("#end").attr("src",t),$(".end").show(),$(".ranking").hide(),newGame()}})}

function getLocalTime(e){var t=new Date(1e3*parseInt(e)),a=t.getFullYear()+"年",n=t.getMonth()+1+"月",o=t.getDate()+"日 ",i=t.getHours(),r=t.getMinutes(),s=":";return r<10&&(s+=0),a+n+o+i+s+r}

function randomString(e){e=e||32;var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",a=t.length,n="";for(i=0;i<e;i++)n+=t.charAt(Math.floor(Math.random()*a));return n}

function disable_scroll(){$("body").on("touchmove",preventDefaultFn)}
function enable_scroll(){$("body").off("touchmove",preventDefaultFn)}
function preventDefaultFn(e){e.preventDefault()}

4==globalData.roomStatus&&setTimeout(function(){
    try{
        var obj=eval("("+globalData.scoreboard+")");
        setTimeout(function(){
            socketModule.processLastScoreboard(obj)
        },0)
    }catch(e){
        console.log(e);
        setTimeout(function(){
            socketModule.processLastScoreboard("")
        },0)
    }
},50);
$(function(){
    $(".place").css("width",140*per);
    $(".place").css("height",140*per);
    $(".place").css("top",270*per);
    $(".place").css("left",195*per);
    sessionStorage.isPaused="false";
    var e,t;
    void 0!==document.hidden?
    (e="hidden",t="visibilitychange"):
    void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange");
    void 0===document.addEventListener||void 0===e?
    alert("This demo requires a browser such as Google Chrome that supports the Page Visibility API."):
    document.addEventListener(t,function(){
        document[e]?(audioModule.audioOn=!1,audioModule.stopSound("backMusic")):
        "true"!==sessionStorage.isPaused&&(console.log("play backMusic"),
        audioModule.audioOn=!0,
        audioModule.stopSound("backMusic"),
        audioModule.playSound("backMusic",!0)
        )},!1)
});